<?php
/**
 * Created by PhpStorm.
 * User: tom_xia
 * Date: 2018/8/13
 * Time: 15:58
 * 首页浮层大图
 */
require_once dirname(__DIR__ ). "/common.php";

use app\cls\tom\Response;
use app\cls\tom\SysResource;

$redis = SysResource::getRedis();
$key = REDIS_PREFIX."big_graph";
$data = $redis->get($key);
if($data){
    $data = json_decode($data,true);
}else{
    $db = SysResource::getDB();
    $date = date("Y-m-d H:i:s");
    $data = $db->select("pic,type,data")->from("big_graph")->where(["start_time<"=>$date,"end_time>"=>$date])
        ->limit(1)->get()->one();
    if($data){
        $data["data"] = json_decode($data["data"],true);
    }
    $redis->setex($key,100,json_encode($data));
}
Response::output(0,"success",$data);
